home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / pctj8402.arc / PWD.ASM < prev    next >
Assembly Source File  |  1983-10-09  |  1KB  |  64 lines

  1.     page    60,132
  2.     title    PWD.ASM
  3. ;    PWD -- Print Working Directory.  This program prints the pathname
  4. ;    of the current directory under PCDOS 2.0.
  5. ;
  6. ;    Author: Bruce Kvam
  7. ;
  8. ;    To assemble this program do:
  9. ;
  10. ;    masm pwd;
  11. ;    link pwd;
  12. ;    exe2bin pwd.exe pwd.com
  13. ;
  14. ;    The files pwd.obj and pwd.exe will be left around and should be erased.
  15. ;    PWD.COM will contain this program.
  16.  
  17. dos    macro    function    ;; Perform a DOS function call.
  18.     mov    ah,function
  19.     int    21h
  20.     endm
  21.  
  22. putc    macro    char        ;; Output a character to the console.
  23.     mov    dl,char
  24.     dos    2
  25.     endm
  26.  
  27. code    segment
  28.  
  29.     assume    cs:code, ds:code, es:code
  30.  
  31.     org    100h
  32. start:
  33.  
  34. ;    First get and print the current drive.
  35.  
  36.     dos    19h        ; get default drive code from DOS.
  37.     add    al,'A'
  38.     putc    al        ; display drive code.
  39.     putc    ':'
  40.     putc    '\'
  41.  
  42. ;    Then get and print the current pathname.
  43.  
  44.     mov    dl,0        ; default drive
  45.     lea    si,pathname
  46.     dos    47h        ; request pathname from DOS.
  47.  
  48. printloop:
  49.     cmp    byte ptr [si],0    ; pathname terminated by 0.
  50.     jz    exit
  51.     putc    [si]
  52.     inc    si        ; point to next character.
  53.     jmp    printloop
  54.  
  55. exit:
  56.     int    20h        ; Return to DOS.
  57.  
  58. ;    Storage area where DOS writes the current pathname (an ASCIIZ
  59. ;    string).
  60.  
  61. pathname db    65 dup (?)
  62.  
  63. code    ends
  64.     end    start